﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;

namespace FileDB
{

    public class DataManager
    {
        public static string DataDir = "data";
        public static string FullDataDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), DataManager.DataDir);

        public static void RemoveData()
        {
            if (Directory.Exists(FullDataDir))
                Directory.Delete(FullDataDir, true);
        }

        public static void Initiaze()
        {
            if (Directory.Exists(FullDataDir))
            {
                // get data
            }
            else
            {
                DirectoryInfo dataDir = Directory.CreateDirectory(FullDataDir);
                dataDir.Attributes = dataDir.Attributes | FileAttributes.Hidden | FileAttributes.ReadOnly;
                var reminderDir = dataDir.CreateSubdirectory(Reminder.RootDir);


                var contractDir = dataDir.CreateSubdirectory(Contract.RootDir);
                var customerDir = dataDir.CreateSubdirectory(Customer.RootDir);
                dataDir.CreateSubdirectory(AdditionInfo.RootDir);
                // default template for reminder
                Reminder.CreateDefaultTemplate();
                Customer.CreateDefaultTemplate();
                // default templete for contract
                Contract.CreateDefaultTemplate();
                AdditionInfo.CreateDefaultTemplate();
            }
        }
    }
}
